package cn.edu.neusoft.maxingxin231.yuejian06.Activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageButton;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Adapter.AttListAdapter;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.AttListBean;
import cn.edu.neusoft.maxingxin231.yuejian06.Iface.AttListIface;
import cn.edu.neusoft.maxingxin231.yuejian06.Listener.ListListener;
import cn.edu.neusoft.maxingxin231.yuejian06.Model.AttListModel;
import cn.edu.neusoft.maxingxin231.yuejian06.R;

public class AttListActivity extends BaseActivity{
    RecyclerView recyclerview;
    ImageButton bt_back;
    private List<AttListBean> items;
    private String club_id,club_name,user_id;
    AttListModel attListModel;
    AttListAdapter attListAdapter;
    private RecyclerView.LayoutManager layoutManager;

    ListListener<AttListBean> attListBeanListListener = new ListListener<AttListBean>() {
        @Override
        public void onResponse(List<AttListBean> list) {
            items=list;
            attListAdapter.setList(list);
        }

        @Override
        public void onFail(String msg) {

        }
    };
    @Override
    void initView() {
        setLayout_file(R.layout.activity_attlist);
        bt_back = (ImageButton)findViewById(R.id.bt_back);
        recyclerview = (RecyclerView)findViewById(R.id.recyclerview);
        club_id = getIntent().getStringExtra("club_id");
        club_name = getIntent().getStringExtra("club_name");
        user_id= getUser_id();
        //创建默认的线性LayoutManager
        layoutManager = new LinearLayoutManager(this);
        //设置布局管理器
        recyclerview.setLayoutManager(layoutManager);
        //如果可以确定每个item的高度是固定的，设置这个选项可以提高性能
        recyclerview.setHasFixedSize(true);
        //创建并设置Adapter
        //list = getData();
        attListAdapter = new AttListAdapter(this);
        attListAdapter.setList(items);
        recyclerview.setAdapter(attListAdapter);


    }

    @Override
    void initEvent() {
        bt_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        AttListModel attListModel = new AttListModel();
        attListModel.getAttList(getUser_id(),attListBeanListListener);
    }

    @Override
    void initData() {

    }

    @Override
    public void onResume() {
        AttListModel attListModel=new AttListModel();
        attListModel.getAttList(getUser_id(),attListBeanListListener);
        super.onResume();
    }
}
